package com.mo.security.service;

import com.mo.security.domain.SimulateUserDB;
import com.mo.security.domain.User;
import com.mo.security.domain.UserDetailsImpl;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 在这里查询数据库里面的用户信息
 */
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        User user = SimulateUserDB.getUserByUsername(username);
        return new UserDetailsImpl(user);
    }
}
